package cn.jiyun;

import com.mongodb.BasicDBObject;
import com.mongodb.MongoClient;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import org.bson.Document;

import java.util.HashMap;
import java.util.logging.Filter;

//Mongo入门Demo
public class MongoDelete {
    //查询所有
    public static void main(String[] args) {
        //创建连接
        MongoClient client=new MongoClient("127.0.0.1");
        //打开数据库
        MongoDatabase spitdb = client.getDatabase("spitdb");
        //获取集合
        MongoCollection<Document> spit = spitdb.getCollection("spit");


        BasicDBObject userid = new BasicDBObject("userid", "1001");


        //插入数据
        spit.deleteOne(userid);
        //关闭连接
        client.close();
    }

}
